package com.ruoyi.situation.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SnowflakeIdUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.control.domain.JingxiaHistory;
import com.ruoyi.control.mapper.*;
import com.ruoyi.control.service.impl.*;
import com.ruoyi.pressure.domain.KyLaneDblcAbnormal;
import com.ruoyi.pressure.mapper.KyLaneDblcAbnormalMapper;
import com.ruoyi.safety.domain.SafetyPointRealHistory;
import com.ruoyi.safety.dto.SafetyPointRealTimeDto;
import com.ruoyi.safety.mapper.SafetyPointAbnormalMapper;
import com.ruoyi.safety.mapper.SafetyPointRealHistoryMapper;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.tube.mapper.SgcdssMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.situation.mapper.SituationMapper;
import com.ruoyi.situation.domain.Situation;
import com.ruoyi.situation.service.ISituationService;

/**
 * 态势估值Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-15
 */
@Service
public class SituationServiceImpl extends ServiceImpl<SituationMapper, Situation> implements ISituationService //修改
{
    @Autowired
    private SituationMapper situationMapper;

    @Autowired
    private SafetyPointAbnormalMapper safetyPointAbnormalMapper;

    @Autowired
    private SysDictDataMapper sysDictDataMapper;

    @Autowired
    private KyLaneDblcAbnormalMapper kyLaneDblcAbnormalMapper;

    @Autowired
    private JingxiaHistoryMapper jingxiaHistoryMapper;

    @Autowired
    private SafetyPointRealHistoryMapper safetyPointRealHistoryMapper;

    @Autowired
    private SgcdssMapper sgcdssMapper;

    @Autowired
    private ElectricityHistoryServiceImpl electricityHistoryService;

    @Autowired
    private BeltHistoryServiceImpl beltHistoryService;

    @Autowired
    private CentralpumphouseHistoryServiceImpl centralpumphouseHistoryService;

    @Autowired
    private Mainventilator1HistoryServiceImpl mainventilator1HistoryService;

    @Autowired
    private Mainventilator2HistoryServiceImpl mainventilator2HistoryService;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询态势估值
     *
     * @param id 态势估值主键
     * @return 态势估值
     */
    @Override
    public Situation selectSituationById(String id) {
        return situationMapper.selectSituationById(id);
    }

    /**
     * 查询态势估值列表
     *
     * @param situation 态势估值
     * @return 态势估值
     */
    @Override
    public List<Situation> selectSituationList(Situation situation) {
        return situationMapper.selectSituationList(situation);
    }

    /**
     * 新增态势估值
     *
     * @param situation 态势估值
     * @return 结果
     */
    @Override
    public int insertSituation(Situation situation) {
        situation.setDataTime(new Date());
        situation.setId(String.valueOf(new SnowflakeIdUtils(5, 8).nextId()));
        return situationMapper.insertSituation(situation);
    }

    /**
     * 修改态势估值
     *
     * @param situation 态势估值
     * @return 结果
     */
    @Override
    public int updateSituation(Situation situation) {
        return situationMapper.updateSituation(situation);
    }

    /**
     * 批量删除态势估值
     *
     * @param ids 需要删除的态势估值主键
     * @return 结果
     */
    @Override
    public int deleteSituationByIds(String[] ids) {
        return situationMapper.deleteSituationByIds(ids);
    }

    /**
     * 删除态势估值信息
     *
     * @param id 态势估值主键
     * @return 结果
     */
    @Override
    public int deleteSituationById(String id) {
        return situationMapper.deleteSituationById(id);
    }

    @Override
    public List<String> getScoreList() {
        final String scoreListKey = "scoreListKey";
        //最低分值
        Double minScore = Double.valueOf("60");
        //得分   wsScore coScore  swScore  kyScore fcScore sgScore
        //返回列表，得分列表  列表顺序  瓦斯(ws+co) 矿压 水 火 粉尘
        ArrayList<String> scoreList = new ArrayList<>();
        //存放对应situationList各个对象得分的scoreMap
        Map<String, Double> scoreMap = new HashMap<>();
        //获取瓦斯、CO等传感器监测阈值列表
        List<Situation> situationList = situationMapper.selectSituationList(null);

        List cacheList = redisCache.getCacheObject(scoreListKey);

        //瓦斯得分
        String wsScore = null;
        //存储key值,方便取分值
        String lowWsKey = "lowWsKey";
        String highWsKey = "highWsKey";
        String coKey = "coKey";
        String dblcKey = "dblcKey";
        String ssllKey = "ssllKey";
        String fcKey = "fcKey";

        final int[] ws = {0};

        //遍历
        situationList.stream().map(situation -> {
            //查询对应的传感器名称
            //stationType的值就是dictValue
            String stationType = situation.getStationType();
            //dictLabel的值是传感器名称
            String dictLabel = sysDictDataMapper.selectDictLabel("status_type", stationType);

//            //记录第一个瓦斯阈值
//            Double wsTempThreshold = 0.0;
            //计算进入次数
//            int ws = 0;
            if (dictLabel.equals("激光甲烷")) {
                //1、查询此刻向前1天的瓦斯点监测值，去situation表拿到对应的瓦斯阈值，用监测值和阈值判断，计算超出阈值次数，计算扣除分值
                //传感器名称===>环境瓦斯
                String queryParam = "激光甲烷";
                //判断对应阈值 当再次进入时，如超出第一次阈值，替换
                Situation wsSituation = situationMapper.selectSituationByStationType(stationType);
                //获取本次的阈值
                Double wsThreshold = Double.valueOf(wsSituation.getThreshold());
//                wsTempThreshold = wsThreshold;

                //瓦斯监测值list
                List<String> valueList = safetyPointRealHistoryMapper.getLastDayValueList(queryParam);
//                List<SafetyPointRealTimeDto> valueList = safetyPointRealHistoryMapper.getWsLastDayValueList(wsThreshold);
                //过滤出大于阈值的个数
                Double count = Double.valueOf((valueList.stream().filter(value -> {
                    return Double.parseDouble(value) > wsThreshold;
                }).count()));

                //超出阈值监测器个数
//                Double count = Double.valueOf(valueList.size());
                //扣除分值
                double weight = Double.parseDouble(wsSituation.getWeight());

                Double deductionScore = count * weight;
                //得分
                Double jwScore = 100 - deductionScore;
                //判断将key赋值给高或低阈值
                if (ws[0] < 1) {
                    ws[0]++;
                    if (jwScore < minScore) {
                        jwScore = minScore;
                        scoreMap.put(lowWsKey, jwScore);
                    } else {
                        scoreMap.put(lowWsKey, jwScore);
                    }
                } else {
                    if (jwScore < minScore) {
                        jwScore = minScore;
                        scoreMap.put(highWsKey, jwScore);
                    } else {
                        scoreMap.put(highWsKey, jwScore);
                    }
                }

                System.out.println("激光甲烷超限次数" + "" + count);
            }


            if (dictLabel.equals("CO")) {
                //传感器名称===>一氧化碳
                String queryParam = "一氧化碳";
                List<String> valueList = safetyPointRealHistoryMapper.getLastDayValueList(queryParam);

                //获取对应阈值
                Situation coSituation = situationMapper.selectSituationByStationType(stationType);
                Double coThreshold = Double.valueOf(coSituation.getThreshold());
                //超出阈值次数
                Double count = Double.valueOf((valueList.stream().filter(value -> {
                    return Double.parseDouble(value) > coThreshold;
                }).count()));
                //扣除分值
                Double weight = Double.parseDouble(coSituation.getWeight());
                Double deductionScore = count * weight;
                //得分
                Double coScore = 100 - deductionScore;
                //判断是否低于最低得分
                if (coScore < minScore) {
                    coScore = minScore;
                    scoreMap.put(coKey, coScore);
                } else {
                    scoreMap.put(coKey, coScore);
                }

                System.out.println("co超限次数" + "" + count);

            }


            if (dictLabel.equals("顶板位移离层")) {
                //顶板离层监测值list
                List<String> valuelist = kyLaneDblcAbnormalMapper.getLastDayValueList();
                //获取对应的阈值
                Situation kySituation = situationMapper.selectSituationByStationType(stationType);
                Double kyThreshold = Double.valueOf(kySituation.getThreshold());
                //过滤出大于阈值的个数
                Double count = Double.valueOf((valuelist.stream().filter(value -> {
                    return Double.parseDouble(value) > kyThreshold;
                }).count()));
                //扣除分值
                Double weight = Double.parseDouble(kySituation.getWeight());
                Double deductionScore = count * weight;
                //得分
                Double dblcScore = 100 - deductionScore;
                //key
                String key = dictLabel + kyThreshold + weight;
                //判断是否低于最低得分
                String kyScore = null;
                if (dblcScore < minScore) {
                    dblcScore = minScore;
                    scoreMap.put(dblcKey, dblcScore);
                } else {
                    scoreMap.put(dblcKey, dblcScore);
                }
//                System.out.println("矿压超限次数" + "" + count);
            }


            if (dictLabel.equals("瞬时流量")) {
                //瞬时流量监测值List
                List<String> valueList = jingxiaHistoryMapper.getLastDayValueList();
                //获取对应的阈值
                Situation swSituation = situationMapper.selectSituationByStationType(stationType);
                Double swThreshold = Double.valueOf(swSituation.getThreshold());
                //过滤出大于阈值的个数
                //计算均值
                List<Double> doubleValueList = new ArrayList<>();
                for (String value : valueList) {
                    double doubleValue = Double.parseDouble(value);
                    doubleValueList.add(doubleValue);
                }
                double average = 0.0;
                if (!doubleValueList.isEmpty()) {
                    double sum = 0.0;
                    for (double value : doubleValueList) {
                        sum += value;
                    }
                    average = sum / doubleValueList.size();
                }
                //计算均值和阈值的差值，小于0设为0
                double i = average - swThreshold;
                if (i < 0) {
                    i = 0;
                }
                Double count = i;
                //扣除分值
                Double weight = Double.parseDouble(swSituation.getWeight());
                Double deductionScore = count * weight;
                //得分
                Double swScore = 100 - deductionScore;
                //判断是否低于最低得分
                if (swScore < minScore) {
                    swScore = minScore;
                    scoreMap.put(ssllKey, swScore);
                } else {
                    scoreMap.put(ssllKey, swScore);
                }
//                System.out.println("瞬时流量超限次数" + "" + count);
            }


            if (dictLabel.equals("束管报警")) {
//                //监测值列表
//                List<String> valueList = sgcdssMapper.getLastDayValueList();
//                //获取阈值
//                Situation sgSituation = situationMapper.selectSituationByStationType(stationType);
//                Double sgThreshold = Double.valueOf(sgSituation.getThreshold());
//                //计算每小时均值  与阈值判断
//

            }


            if (dictLabel.equals("粉尘浓度")) {
                //传感器名称===>粉尘
                String queryParam = "粉尘";
                //粉尘监测值list
                List<String> valueList = safetyPointRealHistoryMapper.getLastDayValueList(queryParam);
                //获取对应的阈值
                Situation fcSituation = situationMapper.selectSituationByStationType(stationType);
                Double fcThreshold = Double.valueOf(fcSituation.getThreshold());
                //过滤出大于阈值的个数
                Double count = Double.valueOf((valueList.stream().filter(value -> {
                    return Double.parseDouble(value) > fcThreshold;
                }).count()));
                //扣除分值
                Double weight = Double.parseDouble(fcSituation.getWeight());
                Double deductionScore = count * weight;
                //得分
                Double fcScore = 100 - deductionScore;
                //判断是否低于最低得分
                if (fcScore < minScore) {
                    fcScore = minScore;
                    scoreMap.put(fcKey, fcScore);
                } else {
                    scoreMap.put(fcKey, fcScore);
                }
//                System.out.println("粉尘超限次数" + "" + count);
            }

            return scoreMap;
        }).collect(Collectors.toList());


//        System.out.println(scoreMap.get(dblcKey));
//        System.out.println(scoreMap.get(ssllKey));
//        System.out.println(scoreMap.get(fcKey));
//        System.out.println(scoreMap.get(coKey));
//        System.out.println(scoreMap.get(lowWsKey));
//        System.out.println(scoreMap.get(highWsKey));

        //瓦斯得分
        Double lowWsScore = scoreMap.get(lowWsKey);
        Double highWsScore = scoreMap.get(highWsKey);
        Double coScore = scoreMap.get(coKey);
        System.out.println("瓦斯" + lowWsScore + "" + highWsScore + "" + coScore);
        Double safeScore = lowWsScore + highWsScore + coScore - 200;
        //矿压得分
        Double kyScore = scoreMap.get(dblcKey);
        //水文得分
        Double swScore = scoreMap.get(ssllKey);
        //束管得分
        Double sgScore = Double.valueOf("90");
        //粉尘得分
        Double fcScore = scoreMap.get(fcKey);
        //总得分  取均值
        Double totalScore = (safeScore + kyScore + swScore + sgScore + fcScore) / 5;

        String value1 = String.format("%.2f", safeScore);
        String value2 = String.format("%.2f", kyScore);
        String value3 = String.format("%.2f", swScore);
        String value4 = String.format("%.2f", sgScore);
        String value5 = String.format("%.2f", fcScore);
        String value6 = String.format("%.2f", totalScore);

        scoreList.add(value1);
        scoreList.add(value2);
        scoreList.add(value3);
        scoreList.add(value4);
        scoreList.add(value5);
        scoreList.add(value6);

        redisCache.setCacheObject(scoreListKey, scoreList);
        return cacheList;
    }

    @Override
    public List<String> getProductScoreList() {
        //最低分值
        Double minScore = Double.valueOf("60");
        //得分   wsScore coScore  swScore  kyScore fcScore sgScore
        //返回列表，得分列表  列表顺序  皮带、供电、排水、通风、采掘（采煤、掘进）、总分
        ArrayList<String> scoreList = new ArrayList<>();
        //存放对应situationList各个对象得分的scoreMap
        Map<String, Double> scoreMap = new HashMap<>();
        //获取故障次数阈值列表
        List<Situation> situationList = situationMapper.selectSituationList(null);

        //获取对应权重
        //扣除分值 = 故障次数 * 权重
//        List<Situation> selectSituationList = situationMapper.selectSituationList(null);

        final String pdKey = "pdKey";
        final String gdKey = "gdKey";
        final String psKey = "psKey";
        final String tfKey = "tfKey";
        final String cjKey = "cjKey";

        situationList.stream().map(situation -> {
            //stationType的值就是dictValue
            String stationType = situation.getStationType();
            //dictLabel的值是  皮带、供电...
            String dictLabel = sysDictDataMapper.selectDictLabel("status_type", stationType);

            if (dictLabel.equals("运输皮带")) {
                //获取对应阈值
                Situation pdSituation = situationMapper.selectSituationByStationType(stationType);
                //获取阈值、权重
                Double threshold = Double.valueOf(pdSituation.getThreshold());
                Double weight = Double.valueOf(pdSituation.getWeight());
                //皮带故障次数

                String pdKey1 = redisCache.getCacheObject("pdKey");
                Double beltTotal = Double.valueOf(pdKey1);
//                Double beltTotal = Double.valueOf(beltHistoryService.getBeltTotal());
                //扣除分值
                Double count = beltTotal - threshold;
                if (count < 0) {
                    count = Double.valueOf(0);
                }
                Double deductionScore = count * weight;
                //得分
                Double pdScore = 100 - deductionScore;
                if (pdScore < minScore) {
                    pdScore = minScore;
                    scoreMap.put(pdKey, pdScore);
                } else {
                    scoreMap.put(pdKey, pdScore);
                }
            }

            if (dictLabel.equals("供电")) {
                //获取对应阈值
                Situation gdSituation = situationMapper.selectSituationByStationType(stationType);
                //获取阈值、权重
                Double threshold = Double.valueOf(gdSituation.getThreshold());
                Double weight = Double.valueOf(gdSituation.getWeight());
                //供电故障次数
                String gdKey1 = redisCache.getCacheObject("gdKey");
                Double electricTotal = Double.valueOf(gdKey1 == null ? "0" : gdKey1);

//                Double electricTotal = Double.valueOf(electricityHistoryService.getElectricTotal());
                //扣除分值
                Double count = electricTotal - threshold;
                if (count < 0) {
                    count = Double.valueOf(0);
                }
                Double deductionScore = count * weight;
                //得分
                Double gdScore = 100 - deductionScore;
                if (gdScore < minScore) {
                    gdScore = minScore;
                    scoreMap.put(gdKey, gdScore);
                } else {
                    scoreMap.put(gdKey, gdScore);
                }
            }

            if (dictLabel.equals("排水")) {
                //获取对应阈值
                Situation psSituation = situationMapper.selectSituationByStationType(stationType);
                //获取阈值、权重
                Double threshold = Double.valueOf(psSituation.getThreshold());
                Double weight = Double.valueOf(psSituation.getWeight());
                //排水故障次数
                String psKey1 = redisCache.getCacheObject("psKey");
                Double waterTotal = Double.valueOf(psKey1);
//                Double waterTotal = Double.valueOf(centralpumphouseHistoryService.getWaterTotal());
                //扣除分值
                Double count = waterTotal - threshold;
                if (count < 0) {
                    count = Double.valueOf(0);
                }
                Double deductionScore = count * weight;
                //得分
                Double psScore = 100 - deductionScore;
                if (psScore < minScore) {
                    psScore = minScore;
                    scoreMap.put(psKey, psScore);
                } else {
                    scoreMap.put(psKey, psScore);
                }
            }

            //采掘  ==>  采煤+掘进


            if (dictLabel.equals("通风")) {
                //获取对应阈值
                Situation tfSituation = situationMapper.selectSituationByStationType(stationType);
                //获取阈值、权重
                Double threshold = Double.valueOf(tfSituation.getThreshold());
                Double weight = Double.valueOf(tfSituation.getWeight());
                //  通风故障次数  ==>  1+2
                String tfOneKey = redisCache.getCacheObject("tfOneKey");
                Double mainOneTotal = Double.valueOf(tfOneKey);
                String tfTwoKey = redisCache.getCacheObject("tfTwoKey");
                Double mainTwoTotal = Double.valueOf(tfTwoKey);
//                Double mainOneTotal = Double.valueOf(mainventilator1HistoryService.getMainOneTotal());
//                Double mainTwoTotal = Double.valueOf(mainventilator2HistoryService.getMainTwoTotal());
                //扣除分值
                Double count = mainOneTotal + mainTwoTotal - threshold;
                if (count < 0) {
                    count = Double.valueOf(0);
                }
                Double deductionScore = count * weight;
                //得分
                Double tfScore = 100 - deductionScore;
                if (tfScore < minScore) {
                    tfScore = minScore;
                    scoreMap.put(tfKey, tfScore);
                } else {
                    scoreMap.put(tfKey, tfScore);
                }
            }
            return scoreMap;
        }).collect(Collectors.toList());

        Double pdScore = scoreMap.get(pdKey);
        Double gdScore = scoreMap.get(gdKey);
        Double psScore = scoreMap.get(psKey);
        Double tfScore = scoreMap.get(tfKey);
        Double cjScore = 90d;
        //总得分
        Double totalScore = (pdScore + gdScore + psScore + tfScore + cjScore) / 5;

        String value1 = String.format("%.2f", pdScore);
        String value2 = String.format("%.2f", gdScore);
        String value3 = String.format("%.2f", psScore);
        String value4 = String.format("%.2f", tfScore);
        String value5 = String.format("%.2f", cjScore);
        String value6 = String.format("%.2f", totalScore);

        scoreList.add(value1);
        scoreList.add(value2);
        scoreList.add(value3);
        scoreList.add(value4);
        scoreList.add(value5);
        scoreList.add(value6);

        return scoreList;
    }

    @Override
    public List<String> getCacheScoreList() {
        final String scoreListKey = "scoreListKey";
        List cacheList = redisCache.getCacheObject(scoreListKey);
        System.out.println("这是缓存数据：" + cacheList);
        return cacheList;
    }

    @Override
    public List<Object> getDeviceFaultList(String type) {
        //皮带 主通风机 局扇  瓦斯泵 空压机 水泵房

        List<Object> valueList = new ArrayList<>();

        if (StringUtils.isNotEmpty(type)) {
            switch (type) {
                case "皮带":
                    //皮带过去7天故障次数==>报警次数
                    List<Object> pdGzValueList = redisCache.getCacheObject("pdGzKey");
                    valueList = pdGzValueList;
                    break;
                case "主通风机":
                    //主扇
                    List<Object> tfGzValueList = redisCache.getCacheObject("tfGzKey");
                    valueList = tfGzValueList;
                    break;
                case "局扇":
                    //局扇
                    List<Object> jsGzValueList = redisCache.getCacheObject("jsGzKey");
                    valueList = jsGzValueList;
                    break;
                case "瓦斯泵":
                    //瓦斯泵
                    List<Object> wsGzValueList = redisCache.getCacheObject("wsGzKey");
                    valueList = wsGzValueList;
                    break;
                case "空压机":
                    //空压机
                    List<Object> kyjGzValueList = redisCache.getCacheObject("kyjGzKey");
                    valueList = kyjGzValueList;
                    break;
                case "水泵房":
                    //水泵房
                    List<Object> sbfGzValueList = redisCache.getCacheObject("sbfGzKey");
                    valueList = sbfGzValueList;
                    break;
            }

        } else {
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
        }

        return valueList;
    }

    @Override
    public List<Object> getDevicePowerList(String type, String num) {
        //皮带 主通风机 局扇  瓦斯泵 空压机 水泵房
        List<Object> valueList = new ArrayList<>();

        if (StringUtils.isNotEmpty(type)) {
            switch (type) {
                case "皮带":
                    if (StringUtils.isNotEmpty(num)) {
                        if ("1".equals(num)) {
                            //主井一部皮带
                        }
                    }
                    break;
                case "主通风机":
                    //主扇
                    if (StringUtils.isNotEmpty(num)) {
                        Map<String, String> fanKeyMap = new HashMap<>();
                        fanKeyMap.put("1", "tfGhKey1");
                        fanKeyMap.put("2", "tfGhKey2");
                        fanKeyMap.put("3", "tfGhKey3");
                        fanKeyMap.put("4", "tfGhKey4");

                        // 从Map中获取对应的Redis键
                        String redisKey = fanKeyMap.get(num);
                        if (redisKey != null) {
                            // 从Redis中获取值列表
                            valueList = redisCache.getCacheObject(redisKey);
                        }

                    }
                    break;
                case "局扇":
                    //局扇
                    if (StringUtils.isNotEmpty(num)) {
                        Map<String, String> fanKeyMap = new HashMap<>();
                        fanKeyMap.put("1", "jsGhKey1");
                        fanKeyMap.put("2", "jsGhKey2");
                        fanKeyMap.put("3", "jsGhKey3");
                        fanKeyMap.put("4", "jsGhKey4");
                        fanKeyMap.put("5", "jsGhKey5");
                        fanKeyMap.put("6", "jsGhKey6");
                        fanKeyMap.put("7", "jsGhKey7");
                        fanKeyMap.put("8", "jsGhKey8");
                        fanKeyMap.put("9", "jsGhKey9");
                        fanKeyMap.put("10", "jsGhKey10");
                        fanKeyMap.put("11", "jsGhKey11");

                        // 从Map中获取对应的Redis键
                        String redisKey = fanKeyMap.get(num);
                        if (redisKey != null) {
                            // 从Redis中获取值列表
                            valueList = redisCache.getCacheObject(redisKey);
                        }
                    }
                    break;
                case "瓦斯泵":
                    //瓦斯泵
                    if (StringUtils.isNotEmpty(num)) {
                        Map<String, String> fanKeyMap = new HashMap<>();
                        fanKeyMap.put("1", "wsGzKey1");
                        fanKeyMap.put("2", "wsGzKey2");
                        fanKeyMap.put("3", "wsGzKey3");
                        fanKeyMap.put("4", "wsGzKey4");

                        // 从Map中获取对应的Redis键
                        String redisKey = fanKeyMap.get(num);
                        if (redisKey != null) {
                            // 从Redis中获取值列表
                            valueList = redisCache.getCacheObject(redisKey);
                        }
                    }
                    break;
                case "空压机":
                    //空压机
                    if (StringUtils.isNotEmpty(num)) {
                        Map<String, String> fanKeyMap = new HashMap<>();
                        fanKeyMap.put("1", "kyjGhKey1");
                        fanKeyMap.put("2", "kyjGhKey2");
                        fanKeyMap.put("3", "kyjGhKey3");

                        // 从Map中获取对应的Redis键
                        String redisKey = fanKeyMap.get(num);
                        if (redisKey != null) {
                            // 从Redis中获取值列表
                            valueList = redisCache.getCacheObject(redisKey);
                        }
                    }
                    break;
                case "水泵房":
                    //水泵房
                    if (StringUtils.isNotEmpty(num)) {
                        Map<String, String> fanKeyMap = new HashMap<>();
                        fanKeyMap.put("1", "sbfGhKey1");
                        fanKeyMap.put("2", "sbfGhKey2");
                        fanKeyMap.put("3", "sbfGhKey3");

                        // 从Map中获取对应的Redis键
                        String redisKey = fanKeyMap.get(num);
                        if (redisKey != null) {
                            // 从Redis中获取值列表
                            valueList = redisCache.getCacheObject(redisKey);
                        }
                    }
                    break;
            }

        } else {
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
            valueList.add("0");
        }

        return valueList;

    }

    @Override
    public List<String> getCacheDeviceFaultList() {
        final String pdKey = "pdKey";
        final String gdKey = "gdKey";
        final String psKey = "psKey";
        final String tfOneKey = "tfOneKey";
        final String tfTwoKey = "tfTwoKey";
        final String cjKey = "cjKey";

        List<String> cacheValueList = new ArrayList<>();
//        String cacheObject = redisCache.getCacheObject(cjKey);
        //采煤、掘进
        cacheValueList.add(0,"0");
        cacheValueList.add(1,"0");
        //通风、皮带、水泵、电力
        String tfValue1 = redisCache.getCacheObject(tfOneKey);
        String tfValue2 = redisCache.getCacheObject(tfTwoKey);

        String pdValue = redisCache.getCacheObject(pdKey);
        String sbfValue = redisCache.getCacheObject(psKey);
        String gdValue = redisCache.getCacheObject(gdKey);

        cacheValueList.add(2,tfValue1);
        cacheValueList.add(3,tfValue2);
        cacheValueList.add(4,pdValue);
        cacheValueList.add(5,sbfValue);
        cacheValueList.add(6,gdValue);

        return cacheValueList;
    }


}
